<?php

namespace app\service\home\topic;

/**
 * 抽奖
 * Class LotteryService
 * @package projects\services\home\topic
 * @author Du
 * @date 2021/3/13
 * @time 18:17
 */
class LotteryService
{

    static public array $prize = [
        'lifelong' => 5,
        'year' => 10,
        'month' => 15,
        'book' => 20,
        'ebook' => 50,
    ];

    /**
     * 返回抽奖信息
     * @return mixed
     * @author Du
     * @date 2021/3/13 18:30
     */
    static public function draw()
    {
        $list = [];
        foreach (self::$prize as $k => $v) {
            for ($i = 0; $i < $v; $i++) {
                $list[] = $k;
            }
        }
        shuffle($list);
        return $list[array_rand($list)];
    }
}